<?php
/*
 * 手机客户端 用户付款信息表函数
 * 2013-11-26
 */
 
 
 
 /**
  * 用户已支付数
  */
 function userwonpaid_userPaidCount($uid){
	$sql = "
			select 
					count(a.uid) as rc 
			from 
					auction_userlastbid a 
					left outer join auction b on a.aid=b.aid 
					left outer join auction_special c on b.asid=c.asid 
					left outer join auction_userwon d on a.wonid=d.wonid 
					left outer join auction_userwonpaid e on d.paidid=e.paidid 
			where 
					a.uid= '".$uid."'
					and a.is_bid=1 
					and a.pay_status=2 
					and a.aid in (select aid from auction where asid in (select asid from auction_special where now() > asclosetime))
	";
	$db = $GLOBALS['db'];
	$db->query($sql);
	
	if($db->next_record()){
		return $db->f("rc");
	}
	return 0;
 }
 
 /**
  * 已发货总数
  */
 function userwonpaid_sendOutCount($uid){
	$sql = "
				select 
						count(a.uid) as rc 
				from 
						auction_userlastbid a 
						left outer join auction b on a.aid=b.aid 
						left outer join auction_special c on b.asid=c.asid 
						left outer join auction_userwon d on a.wonid=d.wonid 
						left outer join auction_userwonpaid e on d.paidid=e.paidid  
				where 
						a.uid = '".$uid."'
						and a.is_bid = 1 
						and a.pay_status=2 
						and a.aid in (select aid from auction where asid in (select asid from auction_special where now() > asclosetime))
						and a.aulbid in (select aulbid from  auction_userwon where paidid in (select paidid from auction_userwonpaid where pay_status=2 and ship_status=2))
	";
	$db = $GLOBALS['db'];
	$db->query($sql);
	
	if($db->next_record()){
		return $db->f("rc");
	}
	return 0;
 }
 
 /**
  * 未发货商品数量
  */
 function userwonpaid_unfilledCount($uid){
	$sql = "
			select
					count(1) as rc
			from
					auction_userwonpaid a
					inner join auction_userwon b on b.paidid = a.paidid
			where 
					a.uid = '".$uid."'
					and (ship_status = 0 or ship_status = 3)
					and a.acttime is not null
	";
	$db = $GLOBALS['db'];
	$db->query($sql);
	
	if($db->next_record()){
		return $db->f("rc");
	}
	return 0;
 }
 ?>